package com.example.administrator.himalaya.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.himalaya.R;
import com.example.administrator.himalaya.entity.castentity.Entity;
import com.squareup.picasso.Picasso;

import java.util.List;


public class MyAdapter3 extends BaseAdapter {
    private Context content;
    private List<Entity.DataEntity.TopRadiosEntity> datas;
    private LayoutInflater inflater;

    public MyAdapter3(Context content, List<Entity.DataEntity.TopRadiosEntity> datas) {
        this.content = content;
        this.datas = datas;
        inflater = LayoutInflater.from(content);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyAdapter2.ViewHolder holder;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.china,parent,false);
            holder = new MyAdapter2.ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (MyAdapter2.ViewHolder) convertView.getTag();
        }
        holder.mTitle.setText(datas.get(position).getName());
        holder.mIng.setText("正在直播:"+datas.get(position).getProgramName());
        holder.mPerson.setText("在线:"+datas.get(position).getProgramScheduleId());
        String img = datas.get(position).getCoverLarge();
        Picasso.with(content).load(img).into(holder.mImageView);
        return convertView;
    }
    static class ViewHolder{
        ImageView mImageView;
        TextView mTitle;
        TextView mIng;
        TextView mPerson;

        public ViewHolder(View view) {
            mImageView = (ImageView) view.findViewById(R.id.china_image);
            mTitle = (TextView) view.findViewById(R.id.china_title);
            mIng = (TextView) view.findViewById(R.id.china_ing);
            mPerson = (TextView) view.findViewById(R.id.china_per);
        }
    }
}
